package mapeditor.mappanel;

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

public class MapMouseMotionListener implements MouseMotionListener {
	private DrawingArea da;
	private boolean isSelecting = false;
	private int startX, startY, currX, currY;

	public MapMouseMotionListener(DrawingArea da) {
		this.da = da;
	}

	@Override
	public void mouseDragged(MouseEvent arg0) {
		if (!isSelecting) {
			startX = arg0.getX();
			startY = arg0.getY();
			isSelecting = !isSelecting;
		} else {
			currX = arg0.getX();
			currY = arg0.getY();
		}
		da.selectingChange(true,startX, startY, currX, currY);
		da.repaint();
	}

	@Override
	public void mouseMoved(MouseEvent arg0) {
		isSelecting = false;
		startX = startY = currX = currY = -1;
		startX=currX=arg0.getX();
		startY=currY=arg0.getY();
		da.selectingChange(false, -1, -1, -1, -1);
		da.clickAt(new Point(arg0.getX(), arg0.getY()));
		da.repaint();
	}

}
